<?php
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';
if ( $act == 'new' ) {
	
	$last_key = end(array_keys($GLOBALS['META_KEY_WORDS']));
	$last_key += 1;
	$GLOBALS['META_KEY_WORDS'][$last_key] = $_REQUEST['ke_word'];
	$GLOBALS['APP_INSTANCE']->refreshSiteKeywordToDb();
}
else if ( $act == 'save' ) {
	$pre_fix = 'key_word_';
	$pre_fix_len = strlen($pre_fix);
	foreach($_POST as $key=>$value){
		$value = trim($value);
		if ( strlen($key) > $pre_fix_len && substr($key, 0, $pre_fix_len) == $pre_fix) {
			$id = substr($key,$pre_fix_len);
			if ( strlen($value) > 0 ) {
				$GLOBALS['META_KEY_WORDS'][$id] = $value;
			}else{
				unset($GLOBALS['META_KEY_WORDS'][$id]);
			}
		}
	}
	$GLOBALS['APP_INSTANCE']->refreshSiteKeywordToDb();
}
?>